home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 23 / Amiga Format AFCD23 (Feb 1998, Issue 107).iso / +look_here_1st!+ / reader_requests / alienbreed3d2 / rawtoiff.s < prev    next >
Text File  |  1997-11-28  |  5KB  |  217 lines

  1.  
  2. * the 'Hello World' program in 68000 Assembler
  3. * the C version can be found in the Intuition manual
  4.  
  5. * this source code (C) HiSoft 1992 All Rights Reserved
  6.  
  7. * for Devpac Amiga Version 2 the following symbols were changed
  8. * to avoid clashes with the new include files:
  9. * Screen->MyScreen, NewScreen->MyNewScreen
  10. * Window->MyWindow, NewWindow->MyNewWindow
  11.  
  12.     opt    c+,d+
  13.  
  14.     include    workbench:utilities/devpac/system            use pre-assembled header
  15.     include    exec/exec_lib.i
  16.     include    intuition/intuition.i
  17.     include    intuition/intuition_lib.i
  18.     include    graphics/graphics_lib.i
  19.     include    graphics/text.i
  20.  
  21. INTUITION_REV    equ    31        v1.1
  22. GRAPHICS_REV    equ    31        v1.1
  23.  
  24. * Open the intuition library
  25.  
  26.  move.l #PALETTEBIT,a0
  27.  move.l #COPIEDPAL+4,a1
  28.  move.w #255,d0
  29.  
  30. copydown:
  31.  move.b 1(a0),(a1)
  32.  move.b 3(a0),4(a1)
  33.  move.b 5(a0),8(a1)
  34.  add.w #6,a0
  35.  add.w #12,a1
  36.  dbra d0,copydown
  37.  
  38.     moveq    #100,d4            default error return code
  39.  
  40.     moveq    #INTUITION_REV,d0    version
  41.     lea    int_name(pc),a1
  42.     CALLEXEC OpenLibrary
  43.     tst.l    d0
  44.     beq    exit_false        if failed then quit
  45.     move.l    d0,_IntuitionBase    else save the pointer
  46.  
  47.     moveq    #GRAPHICS_REV,d0
  48.     lea    graf_name(pc),a1
  49.     CALLEXEC OpenLibrary
  50.     tst.l    d0
  51. ;    beq    exit_closeint        if failed then close Int, exit
  52.     move.l    d0,_GfxBase
  53.  
  54.     lea    MyNewScreen(pc),a0
  55.     CALLINT    OpenScreen        open a screen
  56.     tst.l    d0
  57. ;    beq    exit_closeall        if failed the close both, exit
  58.     move.l    d0,MyScreen
  59.  
  60.     move.l MyScreen,a0
  61.     lea sc_BitMap(a0),a0
  62.     lea bm_Planes(a0),a0
  63.     move.l #RAWSCRN,(a0)
  64.     move.l #RAWSCRN+10240,4(a0)
  65.     move.l #RAWSCRN+10240*2,8(a0)
  66.     move.l #RAWSCRN+10240*3,12(a0)
  67.     move.l #RAWSCRN+10240*4,16(a0)
  68.     move.l #RAWSCRN+10240*5,20(a0)
  69.     move.l #RAWSCRN+10240*6,24(a0)
  70.     move.l #RAWSCRN+10240*7,28(a0)
  71.  
  72. * now initialise a NewWindow structure. This is normally easier to
  73. * do with dc.w/dc.l statement etc, but for comparison with the C
  74. * version we do it like this
  75.     lea    MyNewWindow(pc),a0    good place to start
  76.     move.w    #20,nw_LeftEdge(a0)
  77.     move.w    #20,nw_TopEdge(a0)
  78.     move.w    #300,nw_Width(a0)
  79.     move.w    #100,nw_Height(a0)
  80.     move.b    #0,nw_DetailPen(a0)
  81.     move.b    #1,nw_BlockPen(a0)
  82.     move.l    #window_title,nw_Title(a0)
  83. _temp    set    WINDOWCLOSE!SMART_REFRESH!ACTIVATE!WINDOWSIZING
  84.     move.l    #_temp!WINDOWDRAG!WINDOWDEPTH,nw_Flags(a0)
  85.     move.l    #CLOSEWINDOW,nw_IDCMPFlags(a0)
  86.     move.w    #CUSTOMSCREEN,nw_Type(a0)
  87.     clr.l    nw_FirstGadget(a0)
  88.     clr.l    nw_CheckMark(a0)
  89.     move.l    MyScreen(pc),nw_Screen(a0)
  90.     clr.l    nw_BitMap(a0)
  91.     move.w    #100,nw_MinWidth(a0)
  92.     move.w    #25,nw_MinHeight(a0)
  93.     move.w    #640,nw_MaxWidth(a0)
  94.     move.w    #200,nw_MaxHeight(a0)
  95.  
  96.  move.w #256,COPIEDPAL
  97.  move.w #0,COPIEDPAL+2
  98. LOOKFORME:
  99.  move.l MyScreen,a0
  100.  lea sc_ViewPort(a0),a0
  101.  move.l #COPIEDPAL,a1
  102.  move.l _GfxBase,a6
  103.  jsr -$372(a6)
  104.  
  105.  
  106. * thats it set up, now open the window (a0=NewWindow already)
  107. ;    CALLINT    OpenWindow
  108. ;    tst.l    d0
  109. ;    beq    exit_closescr            if failed
  110. ;    move.l    d0,MyWindow            save it
  111. ;
  112. ;    move.l    d0,a1                window
  113. ;    move.l    wd_RPort(a1),a1            rastport
  114. ;    moveq    #20,d0                X
  115. ;    moveq    #20,d1                Y
  116. ;    CALLGRAF Move                move the cursor
  117. ;
  118. ;    move.l    MyWindow(pc),a0
  119. ;    move.l    wd_RPort(a0),a1            rastport
  120. ;    lea    hello_message(pc),a0
  121. ;    moveq    #11,d0
  122. ;    CALLGRAF Text                print something
  123. ;
  124. ;    move.l    MyWindow(pc),a0
  125. ;    move.l    wd_UserPort(a0),a0
  126. ;    move.b    MP_SIGBIT(a0),d1        (misprint in manual)
  127. ;    moveq    #0,d0
  128. ;    bset    d1,d0                do a shift
  129. ;    CALLEXEC Wait
  130.  
  131. ;    moveq    #0,d4                return code
  132.  
  133. * various exit routines that do tidying up, given a return code in d4
  134.  
  135. ;    move.l    MyWindow(pc),a0
  136. ;    CALLINT CloseWindow
  137.  
  138. ;exit_closescr
  139. ;    move.l    MyScreen(pc),a0
  140. ;    CALLINT CloseScreen
  141.  
  142. ;exit_closeall
  143. ;    move.l    _GfxBase(pc),a1
  144. ;    CALLEXEC CloseLibrary
  145.  
  146. ;exit_closeint
  147. ;    move.l    _IntuitionBase(pc),a1
  148. ;    CALLEXEC CloseLibrary
  149.  
  150. ;done:
  151. ;    bra done
  152.  
  153. exit_false
  154.     moveq #0,d4
  155.     move.l    d4,d0                return code
  156.     rts
  157.  
  158. * the definition of the screen - note that in assembler you
  159. * MUST get the sizes of these fields correct, by consulting either
  160. * the RKM or the header files
  161.  
  162. MyNewScreen    dc.w    0,0        left, top
  163.         dc.w    320,256        width, height
  164.         dc.w    8        depth
  165.         dc.b    0,1        pens
  166.         dc.w    0        viewmodes
  167.         dc.w    CUSTOMSCREEN    type
  168.         dc.l    MyFont        font
  169.         dc.l    screen_title    title
  170.         dc.l    0        gadgets
  171.         dc.l    0        bitmap
  172.  
  173. * my font definition
  174. MyFont    dc.l    font_name
  175.     dc.w    TOPAZ_SIXTY
  176.     dc.b    FS_NORMAL
  177.     dc.b    FPF_ROMFONT
  178.  
  179. * the variables
  180. _IntuitionBase    dc.l    0        Intuition lib pointer
  181. _GfxBase    dc.l    0        graphics lib pointer
  182. MyScreen        dc.l    0
  183. MyWindow        dc.l    0
  184. MyNewWindow    ds.b    nw_SIZE        a buffer
  185.  
  186.  
  187. * some strings
  188. int_name    INTNAME
  189. graf_name    GRAFNAME
  190. hello_message    dc.b    'Hello World'
  191.  
  192. * these are C strings, so have to be null terminated
  193. screen_title    dc.b    'My Own Screen',0
  194. font_name    dc.b    'topaz.font',0
  195. window_title    dc.b    'A Simple Window',0
  196.  
  197.  even
  198.  
  199. COPIEDPAL:
  200.  dc.w 256,0
  201.  ds.l 3*256
  202.  ds.l 10
  203.  
  204. PALETTEBIT:
  205. ; incbin "256palette"
  206. ; dc.w $ffff,$fffe
  207.  
  208.  incbin "ab3:includes/256pal"
  209.  
  210.  
  211.  
  212.  SECTION BGDROP,code_c
  213.  
  214. RAWSCRN:
  215.  incbin "work:rawscrnd"
  216.  
  217.